home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
adg_1_3.zip
/
DLG-OPTS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-02-21
|
5KB
|
168 lines
/****************************************************************************
Module name: Dlg-Opts.C
Programmer : Jeffrey M. Richter.
*****************************************************************************/
#include "..\nowindws.h"
#undef NOCOLOR
#undef NOCTLMGR
#undef NOKERNEL
#undef NOMSG
#undef NOSHOWWINDOW
#undef NOUSER
#undef NOWINMESSAGES
#undef NOWINOFFSETS
#undef NOWINSTYLES
#include <windows.h>
#include <stdlib.h>
#include "dlg-opts.h"
extern HANDLE _hInstance;
// Turns a style ON for a window.
#define SetWindowStyle(hWnd, Style) \
SetWindowLong(hWnd, GWL_STYLE, Style | GetWindowLong(hWnd, GWL_STYLE));
// Turns a style OFF for a window.
#define ResetWindowStyle(hWnd, Style) \
SetWindowLong(hWnd, GWL_STYLE, ~Style & GetWindowLong(hWnd, GWL_STYLE));
#define ENABLECHILDREN (0x80000000L)
#define DISABLECHILDREN (0x00000000L)
BOOL FAR PASCAL EnableChildrenInOptionArea (HWND hWnd, LONG lParam);
void FAR PASCAL ShowArea (BOOL fShowDefAreaOnly, HWND hDlg, HWND hWndDefArea) {
FARPROC fpProc;
RECT rcDlg, rcDefArea;
char szDlgDims[25];
// Save original width and height of dialog box.
GetWindowRect(hDlg, &rcDlg);
// Retrieve coordinates for default area window.
GetWindowRect(hWndDefArea, &rcDefArea);
// Disable controls outside of default area. Any window whose
// left edge > rcDefArea.right || right > rcDefArea.bottom
fpProc = MakeProcInstance(EnableChildrenInOptionArea, _hInstance);
EnumChildWindows(hDlg, fpProc,
(fShowDefAreaOnly ? DISABLECHILDREN : ENABLECHILDREN) |
MAKELONG(rcDefArea.right, rcDefArea.bottom));
FreeProcInstance(fpProc);
if (fShowDefAreaOnly) {
wsprintf(szDlgDims, "%05u %05u",
rcDlg.right - rcDlg.left, rcDlg.bottom - rcDlg.top);
ResetWindowStyle(hWndDefArea, SS_BLACKRECT);
SetWindowStyle(hWndDefArea, SS_LEFT);
SetWindowText(hWndDefArea, szDlgDims);
// Resize dialog box to fit only default area.
SetWindowPos(hDlg, NULL, 0, 0,
rcDefArea.right - rcDlg.left, rcDefArea.bottom - rcDlg.top,
SWP_NOZORDER | SWP_NOMOVE);
// Make sure that the Default area box is hidden.
ShowWindow(hWndDefArea, SW_HIDE);
} else {
GetWindowText(hWndDefArea, szDlgDims, sizeof(szDlgDims));
// Restore dialog box to its original size.
SetWindowPos(hDlg, NULL, 0, 0,
atoi(szDlgDims), atoi(szDlgDims + 6),
SWP_NOZORDER | SWP_NOMOVE);
}
}
BOOL FAR PASCAL EnableChildrenInOptionArea (HWND hWnd, LONG lParam) {
RECT rc;
BOOL fEnable = (lParam & ENABLECHILDREN) != 0;
lParam &= ~ENABLECHILDREN;
// Calculate rectangle occupied by child window in screen coordinates.
GetWindowRect(hWnd, &rc);
// NOTE: Right edge of "Default area" window is in LOWORD(lParam)
// Bottom edge of "Default area" window is in HIWORD(lParam)
// Enable/Disable child if its:
// right edge is >= the right edge of hWndDefArea.
// bottom edge is >= the bottom edge of hWndDefArea.
if ((rc.right >= (int) LOWORD(lParam)) ||
(rc.bottom >= (int) HIWORD(lParam)))
EnableWindow(hWnd, fEnable);
// Allow enumeration to continue until all windows are checked.
return(1);
}
#ifdef _DEMO
//****************************************************************************
// Functions for the ModalLess Dialog Box Demonstration.
#include "dialog.h"
BOOL FAR PASCAL OptionsDlgProc (HWND hDlg, WORD wMsg, WORD wParam, LONG lParam) {
BOOL fProcessed = TRUE;
switch (wMsg) {
case WM_INITDIALOG:
// During initialization, before any windows are shown, resize the
// dialog box so that only the "default" portion is shown.
ShowArea(TRUE, hDlg, GetDlgItem(hDlg, ID_DEFAULTBOX));
break;
case WM_COMMAND:
switch (wParam) {
case IDOK:
case IDCANCEL:
// Terminate dialog box if user selects the "Ok" or
// "Cancel" buttons.
EndDialog(hDlg, wParam);
break;
case ID_OPTIONS:
if (HIWORD(lParam) != BN_CLICKED)
break;
// User selected "Options >>" button, show entire dialog box.
ShowArea(FALSE, hDlg, GetDlgItem(hDlg, ID_DEFAULTBOX));
// The ShowArea(FALSE, ...) function enables all windows
// outside the "default" area. Any windows that should be
// disabled, must be made explicitly disabled here. Note,
// the status of the windows within the "default" area is
// NOT changed.
// Set the focus to the desired control.
SetFocus(GetNextDlgTabItem(hDlg, LOWORD(lParam), 0));
// Disable "Options>>" button.
EnableWindow(LOWORD(lParam), FALSE);
break;
default:
fProcessed = FALSE;
break;
}
break;
default:
fProcessed = FALSE;
break;
}
return(fProcessed);
}
#endif